import service from '@/utils/request';

const prefix = '/exam';
export function getExamListService(data) {
  return service({
    url: `${prefix}/list`,
    method: 'get',
    params: data,
  });
}

export function addExamService(data = {}) {
  return service({
    url: `${prefix}/add`,
    method: 'post',
    data,
  });
}

export function questionAddService(examId, questionIds = []) {
  return service({
    url: `${prefix}/question/add`,
    method: 'post',
    data: { examId, questionIds },
  });
}

export function getExamDetailService(examId) {
  return service({
    url: `${prefix}/detail`,
    method: 'get',
    params: { examId },
  });
}

export function editExamService(data) {
  return service({
    url: `${prefix}/edit`,
    method: 'put',
    data,
  });
}

export function deleteExamQuestionByIdService(examId, questionId) {
  return service({
    url: `${prefix}/question/delete`,
    method: 'delete',
    params: { examId, questionId },
  });
}

export function deleteExamByIdService(examId) {
  return service({
    url: `${prefix}/delete`,
    method: 'delete',
    params: { examId },
  });
}

export function publishExamService(examId) {
  return service({
    url: `${prefix}/publish`,
    method: 'put',
    params: { examId },
  });
}

export function cancelPublishExamService(examId) {
  return service({
    url: `${prefix}/cancelPublish`,
    method: 'put',
    params: { examId },
  });
}


export function getExamGroupIdByExamIdService(examId) { 
  return service({
    url: `${prefix}/user/group`,
    method: 'get',
    params: { examId },
  });
}